lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

File system layout.html (5085B)


      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      3 <html><head><link rel="stylesheet" href="sitewide.css"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 7.6 (457297)"/><meta name="altitude" content="-4.349451065063477"/><meta name="author" content="Alex Balgavy"/><meta name="created" content="2018-12-19 00:03:10 +0000"/><meta name="latitude" content="52.30032348632812"/><meta name="longitude" content="4.98812990790774"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2018-12-19 00:03:52 +0000"/><title>File system layout</title></head><body><div style="">on real disk, there are number of partitions (primary, extended, subpartitions). each partition can hold different filesystem<br/></div><div style=""><br/></div><div style=""><img src="File%20system%20layout.resources/B75E558A-A498-407B-A14B-95A64A57BDEE.png" height="235" width="538"/></div><div><br/></div><div>one partition is flagged as 'active' partition</div><div>MBR has boot code to locate active primary partition and execute boot block</div><div><br/></div><div>partitions: primary, extended, and subpartitions</div><div><br/></div><div><span style="font-weight: bold;">how to store files on disk:
      4 </span></div><div>contiguous allocation:
      5 </div><ul><li><div>files as contiguous stream of bytes</div></li><li><div>but prone to fragmentation, requires max file size</div></li></ul><div><br/></div><div>block-based (logically contiguous, but actually stored anywhere on disk):
      6 </div><ul><li><div>linked list
      7 </div></li><ul><li><div>by keeping in-band metadata, end up with strange block size (2 or 4 kb data, with some bytes to hold pointer)</div></li><li><div>good for sequential access patterns, but random...not so much</div></li><li><div>pointers are pointing to blocks on disk (NOT memory)</div></li><li><div><img src="File%20system%20layout.resources/40D5993F-B020-40C1-9824-EBBC03D73BBD.png" height="373" width="515"/></div></li></ul><li><div>file allocation table (FAT)
      8 </div></li><ul><li><div>move in-band metadata out of band</div></li><li><div>the table is stored in kernel memory</div></li><li><div>holds starting points of files</div></li><li><div>every row refers to a block of memory</div></li><li><div>worked well for a while, but for modern sizes it is not possible to hold the table in memory</div></li><li><div><img src="File%20system%20layout.resources/AE00280E-4C0C-4F43-9A0C-D23CFBB31755.png" height="377" width="337"/></div></li></ul><li><div>I-nodes
      9 </div></li><ul><li><div>just a FUCKTON of indirections</div></li><li><div><img src="File%20system%20layout.resources/283F1231-AF87-4602-BECA-6737A8A4275E.png" height="477" width="776"/></div></li></ul></ul><div><br/></div><div><span style="font-weight: bold;">How to implement directories
     10 </span></div><div><img src="File%20system%20layout.resources/46733DBC-ADF2-4E9B-8AA6-CA1D57187394.png" height="189" width="839"/></div><div> <img src="File%20system%20layout.resources/EBD4A225-FAB2-45DD-843E-E8C8CD94786F.png" height="178" width="835"/></div><div><br/></div><div>FAT layout:
     11 </div><ul><li><div>PBR stores "boot block"</div></li><li><div>reserved is later used for filesystem info</div></li><li><div>FAT #: preallocated file allocation table</div></li><li><div>preallocated root dir (FAT12/FAT16)</div></li><li><div>clusters are addressable blocks (FAT has chains indexed by starting cluster)</div></li><li><div><img src="File%20system%20layout.resources/A60F5F9E-2CC1-4B68-8CD0-B08E43BB0F5F.png" height="133" width="848"/></div></li></ul><div>UNIX dir entry:
     12 </div><ul><li><div>dir entry stores only name and inode number</div></li><li><div>attributes are stored in inode</div></li><li><div>one inode per file, first inode is root</div></li><li><div>links:
     13 </div></li><ul><li><div>hard link -- if 10 hard links to a file, then a single file with 10 dir entries pointing to that file (inode)</div></li><li><div>soft (symbolic) link -- if 10 soft links to a file, literally 10 files. can point to anything, but if file gets deleted, the link is dead.</div></li></ul><li><div>where are the inode stored? it depends, as always.</div></li></ul><div><br/></div><div style="margin-left: 40px;"> <img src="File%20system%20layout.resources/F73C52E4-0455-469F-A7F0-2CEAD32AAE54.png" height="286" width="831"/></div><div style="margin-left: 40px;"><img src="File%20system%20layout.resources/6CB2B618-CF63-4A55-AFE2-B295F06E7390.png" height="212" width="428"/></div><div style="margin-left: 40px;"><img src="File%20system%20layout.resources/7826DCF8-7F53-49E1-976F-BCAF52D8674A.png" height="509" width="948"/></div><div><br/></div><div>how to manage disk space
     14 </div><ul><li><div>linked list vs bitmap (linked list actually works really well here)</div></li></ul><div style="margin-left: 40px;"><img src="File%20system%20layout.resources/31DF59DF-579C-4326-ABD5-D5A340CB77E1.png" height="532" width="806"/></div><div><br/></div></body></html>